package com.syt.test


fun printAll(Strings: Collection<String>) {
    for (string in Strings) {
        println("string = $string")
    }
}

/**
 * 列表筛选
 * @receiver List<String> 需要筛选的列表
 * @param shortWords MutableList<String> 筛选结果
 * @param maxLength Int 每个元素的最大长度
 */
fun List<String>.getShortWordsTo(shortWords: MutableList<String>, maxLength: Int) {
    this.filterTo(shortWords) {
        it.length <= maxLength
    }
    val articles = setOf("a", "A", "an", "An", "the", "The")
    shortWords -= articles
}

fun main() {

    val numbers = mutableListOf("one", "two", "four", "three")
    numbers.add("five")

    println("numbers = ${numbers}")

    val words = "A long time ago in a galaxy far far away".split(" ")
    val shortWords = mutableListOf<String>()
    words.getShortWordsTo(shortWords, 3)
    println(shortWords)

    val str = "11113456437251班神雨田123411113456437251班神雨田123411113456437251班神雨田123411113456437251班神雨田123411113456437251班神雨田123411113456437251班神雨田1234"

    println(System.currentTimeMillis())

    for (number in 1..10000) {
        NameUtils.handleClassNumber(str)
    }

    println(System.currentTimeMillis())

    for (number in 1..10000) {
        NameUtils.handleClassNumber2(str)
    }

    println(System.currentTimeMillis())

}

